/*
*************************** C HEADER FILE ************************************

project   : General Template
filename  : IO68K.H
version   : 2
date      : August 03, 2010

******************************************************************************

Copyright (c) 2003, P.K. van der Vlugt
All rights reserved.

******************************************************************************

VERSION HISTORY:
----------------------------
Version      : 1
Date         : August 02, 2010
Revised by   : P.K. van der Vlugt
Description  : Original version.

Version      : 2
Date         : August 03, 2010
Revised by   : P.K. van der Vlugt
Description  : * Changed input sampling time to 50 msec.
               * Added support for different CAN physical layers.
               * Added activation of the reference output.

******************************************************************************
*/

#ifndef  _IO68K_INCLUDED
#define  _IO68K_INCLUDED

/****************************************************************************/
/**                                                                        **/
/**                              MODULES USED                              **/
/**                                                                        **/
/****************************************************************************/

#include "cdat68k.h"

/****************************************************************************/
/**                                                                        **/
/**                        DEFINITIONS AND MACROS                          **/
/**                                                                        **/
/****************************************************************************/

/**** Error Codes ****/
#define NO_ERR    0
#define ERR_N     1
#define ERR_V     2
#define ERR_D     3
#define ERR_P     4


/****************************************************************************/
/**                                                                        **/
/**                        TYPEDEFS AND STRUCTURES                         **/
/**                                                                        **/
/****************************************************************************/



/****************************************************************************/
/**                                                                        **/
/**                         EXPORTED VARIABLES                             **/
/**                                                                        **/
/****************************************************************************/

#ifndef _IO68K_C_SRC


#endif

/****************************************************************************/
/**                                                                        **/
/**                       EXPORTED FUNCTIONS                               **/
/**                                                                        **/
/****************************************************************************/

/****************************************************************************/
int8u ReadSwAll (void);
/****************************************************************************/
/*
 Description:  Read logic of all (8) input switches. Each bit of returned
 value is coresponding to each SW number (0-7). Interrupt should be disable
 before calling this function.
 Parameters:  None.
 Returns:  Logic values of SW0 - SW7.
*/


/****************************************************************************/
int8u ReadSwN (int8u n);
/****************************************************************************/
/*
 Description:  Read logic of the Nth input SW. Interrupt should be disable
 before call this function. This function will store the error code in the
 variable whose address provide by the calling function.
 Parameters: n is 0 - 7 ; coresponding to the Nth SW.
 Returns:  0x00 ; if SW is closed.
           0x01 ; if SW is opened.
           0xff ; if n is more than 7.
*/

/****************************************************************************/
int8u ReadLedAll (void);
/****************************************************************************/
/*
 Description:  Read logic of all (8) LEDs. Each bit of returned value is
 coresponding to each LED number (0-7). Interrupt should be disable before
 calling this function.
 Parameters:  None.
 Returns:   Logic values of LED0 - LED7.
*/

/****************************************************************************/
int8u ReadLedN (int8u n);
/****************************************************************************/
/*
 Description:  Read logic of the Nth LED. Interrupt should be disable before
 callihg this function.
 Parameters:  0 - 7 ; coresponding to the Nth LED.
 Returns:  0x00 ; if LED is OFF.
           0x01 ; if LED is ON.
           0xff ; if n is more than 7.
*/

/****************************************************************************/
void WriteLedAll (int8u v);
/****************************************************************************/
/*
 Description:  Write logics to all (8) LEDs. Each bit of parameter value is
 coresponding to each LED number (0-7). Interrupt should be disable before
 calling this function.
 Parameters:  Logics output to LEDs (0-0xff).
 Returns:   None.
*/

/****************************************************************************/
int8u WriteLedN (int8u n , int8u v);
/****************************************************************************/
/*
 Description:  Write logic to the Nth LED. Interrupt should be disable before
 calling this function.
 Parameters: n = 0 - 7 ; coresponding to the Nth LED.
             v = 0 or 1 ; logic value to the Nth LED.
 Returns: An error code.
          NO_ERR ; if no error.
          ERR_N  ; if parameter n is more than 7.
          ERR_V  ; if parameter v is other than 0 or 1.
*/

/****************************************************************************/
int8u WriteDigitN (int8u n , int8u d);
/****************************************************************************/
/*
 Description:  Write 1 digit of decimal value to the Nth digit of 7-segment
 display. Digit 0 is the left most, digit 3 is the right most.
 Interrupt should be disable before calling this function.
 Parameters: n = 0 - 3 ; coresponding to the Nth digit.
             d = 0 - 9 ; decimal value to the Nth digit.
 Returns: An error code.
          NO_ERR ; if no error.
          ERR_N  ; if parameter n is more than 3.
          ERR_D ; if parameter d is more than 0 to 9.
*/


/****************************************************************************/
int8u WriteDigitAll (int16u d);
/****************************************************************************/
/*
 Description:  Write decimal value (0 - 9999)to 4 digits of 7-segment
 display. Interrupt should be disable before calling this function.
 Parameters: d = 0 - 9999 ; decimal value to display.
 Returns: An error code.
          NO_ERR ; if no error.
          ERR_D ; if parameter d is other than 0 to 9999.
*/

/****************************************************************************/
int8u WriteDigitPointN (int8u n, int8u v);
/****************************************************************************/
/*
 Description:  Write decimal point to the Nth digit of 7-segment display.
 Digit 0 is the left most, digit 3 is the right most.
 Interrupt should be disable before calling this function.
 Parameters: n = 0 - 3 ; coresponding to the Nth digit.
             v = 0 ; decimal pointh off
               = 1 ; decimal point ON.
 Returns: An error code.
          ERR_N  ; if parameter n is more than 3.
          ERR_V  ; if parameter v is other than 0 or 1.
*/

/****************************************************************************/
int8u ReadSlider (void);
/****************************************************************************/
/*
 Description:  Read decimal value of the input slider. Interrupt should be
 disable before callihg this function.
 Parameters: None.
 Returns:  0 - 255
*/

/****************************************************************************/
void WriteBar (int8u d);
/****************************************************************************/
/*
 Description:  Write decimal value (0-255) to bargraph. Interrupt should be
 disable before callihg this function.
 Parameters: d = 0 - 255 ; decimal vaule to bargraph.
 Returns:  None.
*/

/****************************************************************************/

#endif

/****************************************************************************/
/**                                                                        **/
/**                              EOF                                       **/
/**                                                                        **/
/****************************************************************************/